package com.munhrasoft.elearning.business.entities;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;

@Entity
@NamedQueries(value = {
    @NamedQuery(name = "findAllQuestions", query = "SELECT q FROM Questions q"),
    @NamedQuery(name = "findQuestionByTitle", query = "SELECT q FROM Questions q WHERE lower(q.title) "
            + "LIKE :title") })
@SequenceGenerator(name = "questionsSeq", initialValue = 1, allocationSize = 1)
public class Questions {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "questionsSeq")
    private Long           id;
    private String         title;
    private String         questionText;
    private Long           points;
    private boolean        correct;

    @ManyToMany(fetch = FetchType.LAZY)
    private List<Students> studentsThatAnswr;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getQuestionText() {
        return questionText;
    }

    public void setQuestionText(String questionText) {
        this.questionText = questionText;
    }

    public Long getPoints() {
        return points;
    }

    public void setPoints(Long points) {
        this.points = points;
    }

    public boolean isCorrect() {
        return correct;
    }

    public void setCorrect(boolean correct) {
        this.correct = correct;
    }

    public List<Students> getStudentsThatAnswr() {
        return studentsThatAnswr;
    }

    public void setStudentsThatAnswr(List<Students> studentsThatAnswr) {
        this.studentsThatAnswr = studentsThatAnswr;
    }

}
